import request from '@/utils/request'

// 查询MDM依赖关系管理列表
export function listLink(query) {
  return request({
    url: '/rm/link/list',
    method: 'get',
    params: query
  })
}

// 查询MDM依赖关系管理详细
export function getLink(id) {
  return request({
    url: '/rm/link/' + id,
    method: 'get'
  })
}

// 新增MDM依赖关系管理
export function addLink(data) {
  return request({
    url: '/rm/link',
    method: 'post',
    data: data
  })
}

// 修改MDM依赖关系管理
export function updateLink(data) {
  return request({
    url: '/rm/link',
    method: 'put',
    data: data
  })
}

// 删除MDM依赖关系管理
export function delLink(id) {
  return request({
    url: '/rm/link/' + id,
    method: 'delete'
  })
}

// 获取MDM所有的item
export function selectAllItem() {
  return request({
    url: '/rm/link/selectAllItem',
    method: 'get'
  })
}

// 根据itemId查询所有被关联的category
export function selectCategoryByLink(id,type) {
  return request({
    url: '/rm/link/selectCategoryByLink/' + id +'/' +type,
    method: 'get'
  })
}

// 根据itemId查询所有被关联的category
export function selectCategoryNotByLink(type) {
  return request({
    url: '/rm/link/selectCategoryNotByLink/' +type,
    method: 'get'
  })
}

// 新增或修改Item的关联关系
export function batchLink(data) {
  return request({
    url: '/rm/link/batchLink',
    method: 'post',
    data: data
  })
}

//获取原料MDM穿梭框左边信息
export function selectCategoryByLeft(type) {
  return request({
    url: '/rm/property/selectCategoryByLeft/' + type,
    method: 'get'
  })
}

//根据id获取所有与他绑定的
export function selectCategoryBySource(id,type) {
  return request({
    url: '/rm/property/selectCategoryBySource/' + id +'/' + type,
    method: 'get'
  })
}

// 原料批量添加MDM动态属性
export function batchAddProperty(data) {
  return request({
    url: '/rm/property/batchAddProperty',
    method: 'post',
    data: data
  })
}

// 查询成分原料动态属性管理列表
export function listProperty(query) {
  return request({
    url: '/rm/property/list',
    method: 'get',
    params: query
  })
}

// 查询成分原料动态属性管理详细
export function getProperty(id) {
  return request({
    url: '/rm/property/' + id,
    method: 'get'
  })
}

// 新增成分原料动态属性管理
export function addProperty(data) {
  return request({
    url: '/rm/property',
    method: 'post',
    data: data
  })
}

// 修改成分原料动态属性管理
export function updateProperty(data) {
  return request({
    url: '/rm/property',
    method: 'put',
    data: data
  })
}

// 删除成分原料动态属性管理
export function delProperty(id) {
  return request({
    url: '/rm/property/' + id,
    method: 'delete'
  })
}

// 查询所有的动态属性类型
export function selectAllType() {
  return request({
    url: '/rm/property/selectAllType',
    method: 'get'
  })
}

// 查询所有未聚合的集合
export function selectClusterNotByGroup(type) {
  return request({
    url: '/rm/property/selectClusterNotByGroup/'+type,
    method: 'get'
  })
}

// 查询所有未分区的集合
export function selectGroupNotBySection(type){
  return request({
    url: '/rm/property/selectGroupNotBySection/'+type,
    method: 'get'
  })
}

// 查询所有未分区的集合
export function selectSectionCancel(type) {
  return request({
    url: '/rm/property/selectSectionCancel/'+ type,
    method: 'get'
  })
}

// mdmCluster删除动态属性
export function deleteByCluster(data) {
  return request({
    url: '/rm/property/deleteByCluster',
    method: 'post',
    data: data
  })
}

//聚合成组接口
export function addGroup(data) {
  return request({
    url: '/rm/property/addGroup',
    method: 'post',
    data: data
  })
}

// 拆分组接口
export function cancelGroup(groupName,type) {
  return request({
    url: '/rm/property/cancelGroup/' + groupName + '/' + type,
    method: 'get'
  })
}

//添加section接口
export function addSection(data) {
  return request({
    url: '/rm/property/addSection',
    method: 'post',
    data: data
  })
}

// 拆分section接口
export function cancelSection(inrmSectionId) {
  return request({
    url: '/rm/property/cancelSection/' + inrmSectionId,
    method: 'get'
  })
}

//tree型结构
export function selectAllByTree(type) {
  return request({
    url: '/rm/property/selectAllByTree/' + type,
    method: 'get'
  })
}

//左边属性
export function addMdmByLeft(type) {
  return request({
    url: '/rm/property/addMdmByLeft/' + type,
    method: 'get'
  })
}
